package com.may.wind.exception;

import com.may.wind.enums.ResultEnum;

/**
 * 自定一个异常类，捕获针对项目或业务的异常
 * 异常的对象信息补充到统一结果枚举中
 */
public class GlobalRunningException extends RuntimeException {
    private Integer code;

    public GlobalRunningException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public GlobalRunningException(ResultEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String toString() {
        return "GlobalRunningException{" + "code=" + code + ", message=" + this.getMessage() + '}';
    }
}
